-- following options are the default
-- each of these are documented in `:help nvim-tree.OPTION_NAME`

local status_ok, nvim_tree = pcall(require, 'nvim-tree')
if not status_ok then
  return
end

-- local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
-- if not config_status_ok then
--   return
-- end

-- local tree_cb = nvim_tree_config.nvim_tree_callback

nvim_tree.setup {
  disable_netrw = true,
  hijack_netrw = true,
  auto_reload_on_write = true,
  open_on_tab = false,
  open_on_setup = false,
  hijack_cursor = false,
  hijack_unnamed_buffer_when_opening = false,
  ignore_buffer_on_setup = false,
  respect_buf_cwd = false,
  create_in_closed_folder = false,
  view = {
    width = 40,
    side = 'left',
    hide_root_folder = true,
    preserve_window_proportions = false,
    number = true,
    relativenumber = true,
    signcolumn = 'yes',
    mappings = {
      custom_only = false,
      list = {
        -- user mappings goes here
        { key = '<C-e>', action = '' }, -- disable <C-e> for edit file
        -- { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
        -- { key = "h", cb = tree_cb "close_node" },
        -- { key = "v", cb = tree_cb "vsplit" },
      },
    },
  },
  renderer = {
    root_folder_modifier = ':p:.',
    highlight_git = true,
    highlight_opened_files = 'none',
    add_trailing = false,
    group_empty = false,
    indent_markers = {
      enable = true,
      icons = {
        corner = '└',
        edge = '│',
        item = '│',
        none = ' ',
      },
    },
    icons = {
      webdev_colors = false,
      git_placement = 'signcolumn',
      padding = ' ',
      symlink_arrow = ' >> ',
      show = {
        file = true,
        folder = true,
        folder_arrow = false,
        git = true,
      },
      glyphs = {
        default = '',
        symlink = '',
        folder = {
          arrow_closed = '',
          arrow_open = '',
          default = '',
          open = '',
          empty = '',
          empty_open = '',
          symlink = '',
          symlink_open = '',
        },
        git = {
          unstaged = '',
          staged = 'S',
          unmerged = '',
          renamed = '➜',
          untracked = 'U',
          deleted = '',
          ignored = '◌',
        },
      },
    },
    special_files = { 'Cargo.toml', 'Makefile', 'README.md', 'readme.md' },
    symlink_destination = true,
  },
  hijack_directories = {
    enable = true,
    auto_open = true,
  },
  update_focused_file = {
    enable = true,
    update_cwd = false,
    ignore_list = {},
  },
  ignore_ft_on_setup = {
    'startify',
    'dashboard',
    'alpha'
  },
  system_open = {
    cmd = nil,
    args = {},
  },
  diagnostics = {
    enable = false,
    icons = {
      hint = '',
      info = '',
      warning = '',
      error = '',
    },
  },
  filters = {
    dotfiles = false,
    custom = {
      'node_modules', '.cache'
    },
    exclude = {
      '.env', 'doc'
    }
  },
  git = {
    enable = true,
    ignore = true,
    timeout = 500,
  },
  actions = {
    change_dir = {
      enable = true,
      global = false,
    },
    open_file = {
      quit_on_open = false,
      resize_window = true,
      window_picker = {
        enable = true,
        chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
        exclude = {
          filetype = { 'notify', 'packer', 'qf', 'diff', 'fugitive', 'fugitiveblame' },
          buftype = { 'nofile', 'terminal', 'help' },
        },
      },
    },
  },
  trash = {
    cmd = 'trash',
    require_confirm = true,
  }
}

vim.cmd [[
hi NvimTreeRootFolder   guifg=#CCB17A guibg=NONE
hi NvimTreeFolderIcon   guifg=#CCB17A guibg=NONE
hi NvimTreeIndentMarker guifg=#3C3C3C guibg=NONE
hi NvimTreeGitDirty     guifg=#CCB17A guibg=NONE
hi NvimTreeGitStaged    guifg=#CCB17A guibg=NONE
hi NvimTreeGitMerge     guifg=#CCB17A guibg=NONE
hi NvimTreeGitRenamed   guifg=#CCB17A guibg=NONE
hi NvimTreeGitNew       guifg=#CCB17A guibg=NONE
]]
